package com.itheima.service.Impl;

import com.itheima.mapper.ReportMapper;
import com.itheima.pojo.JobOption;
import com.itheima.pojo.StudentOption;
import com.itheima.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    private ReportMapper reportMapper;

    @Override
    public List<Map<String, Integer>> empGenderData() {
        List<Map<String, Integer>> map = reportMapper.empGenderData();
        return map;
    }

    @Override
    public JobOption empJobData() {
        List<HashMap> list = reportMapper.countEmpJobData();

        List<Object> jobList = list.stream().map(dataMap -> dataMap.get("pos")).toList();
        List<Object> dataList = list.stream().map(dataMap -> dataMap.get("total")).toList();
        return new JobOption(jobList,dataList);
    }

    @Override
    public List<Map<String, Integer>> studentDegreeData() {
        List<Map<String, Integer>> map = reportMapper.studentDegreeData();
        return map;
    }

    @Override
    public StudentOption studentCountData() {
        List<HashMap> list = reportMapper.studentCountData();

        List<Object> studentList = list.stream().map(dataMap -> dataMap.get("pos")).toList();
        List<Object> dataList = list.stream().map(dataMap -> dataMap.get("total")).toList();

        return new StudentOption(studentList,dataList);
    }


}
